<script type="text/javascript"> 
//<![CDATA[
$(document).ready(function() {
	new AjaxUpload("avatar_upload", {name: "image",
		action: base_url+"backend/avatar_upload.php",
		responseType: "json",
		onChange: function () {avatar_preupload()},
		onComplete: function (f, r) {avatar_uploaded(f, r)}
	});
});

function avatar_preupload() {
	$('#avatar_upload').attr("disabled", true);
	$('#avatar_indicator').html('<img src="'+base_static+'img/common/indicator_horizontal.gif"/>');
}
 
function avatar_uploaded(file, response) {
	if (response.error) {
		alert(response.error);
	} 
	if (response.avatar_url.length > 0) { 
		$("#avatar").attr("src",response.avatar_url);
	}
	$('#avatar_indicator').html('');
	$('#avatar_upload').attr("disabled", false);
}
 
function select_meta(input, meta) {
	if (input.checked) new_value = true;
	else new_value = false;
	meta_id = '#meta-'+meta;
	$(meta_id+' input').attr({checked: new_value});
	return false;
}
//]]>
</script>
